var t, a = require("../../../../@babel/runtime/helpers/defineProperty"), e = getApp();

Component({
    properties: {},
    pageLifetimes: {
        show: function() {
            this.setData({
                index: 0,
                password_show: !1,
                show_pay: !1,
                show_dialog: !1,
                pay_index: 0,
                is_has: !1
            }), this.getData();
        },
        hide: function() {},
        resize: function() {}
    },
    lifetimes: {
        ready: function() {
            this.getData(), this.get_buy_data(), this._getBalancePwdInfo();
        }
    },
    data: (t = {
        tabbar_active: 0,
        index: 0,
        sex: [ "会员", "管理员" ],
        type: [ "登录密码", "支付密码" ],
        radio: 1,
        count: "",
        show_dialog: !1,
        show1: !1,
        cservice: "",
        service_mobile: "",
        service_QRcode: "",
        active: 0,
        password_open: !0,
        password: "",
        show_pay: !1,
        pay_index: 0,
        role: "member",
        listData: [],
        background: [ "demo-text-1", "demo-text-2", "demo-text-3" ],
        indicatorDots: !0,
        vertical: !1,
        autoplay: !1,
        interval: 2e3,
        duration: 500,
        datas: {},
        password_show: !1,
        subscribe_title: "",
        activity_id: "",
        active_value: 0,
        require_pwd: !1,
        is_admin: !1,
        carousel_min_app_link: "",
        banner_min_app_link: "",
        banner_thumb_url: "",
        carousel_imgs_url: [],
        sign_multiple: "",
        activity_list: []
    }, a(t, "service_mobile", ""), a(t, "service_QRcode", ""), a(t, "Height", 0), a(t, "LastHeight", 0), 
    a(t, "Banner_Height", 0), a(t, "Last_Banner_Height", 0), a(t, "is_has", !1), t),
    methods: {
        closePop: function() {
            this.setData({
                show1: !1
            });
        },
        skip: function(t) {
            "carousel" == t.currentTarget.dataset.type ? wx.navigateTo({
                url: "".concat(this.data.carousel_min_app_link)
            }) : wx.navigateTo({
                url: "".concat(this.data.banner_min_app_link)
            });
        },
        getKeFu: function() {
            var t = this, a = e.getNetAddresss("goods.customer-service.index");
            e._postNetWork({
                url: a,
                success: function(a) {
                    var e = a.data;
                    1 == e.result && t.setData({
                        cservice: e.data.cservice,
                        service_QRcode: e.data.service_QRcode,
                        service_mobile: e.data.service_mobile
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        getData: function() {
            var t = this;
            e._getNetWork({
                url: e.getNetAddresss("plugin.sign-buy.frontend.sign-buy-page.home"),
                success: function(a) {
                    var i = a.data, s = i.data, n = i.result, r = i.msg;
                    if (0 == n) return e.tips(r);
                    var o = s.carousel_min_app_link, d = s.banner_min_app_link, c = s.banner_thumb_url, u = s.carousel_imgs_url, _ = s.sign_multiple, l = s.activity_list;
                    t.setData({
                        carousel_min_app_link: o,
                        banner_min_app_link: d,
                        banner_thumb_url: c,
                        carousel_imgs_url: u,
                        sign_multiple: _,
                        activity_list: l
                    }), u && 1 == u.length && t.setData({
                        indicatorDots: !1
                    });
                }
            });
        },
        sign_subscribe_handle: function(t) {
            var a = t.detail.item;
            this.setData({
                show_dialog: !0,
                datas: a,
                subscribe_title: a.activity_name,
                activity_id: a.stage_id,
                count: "",
                password: ""
            });
        },
        get_buy_data: function() {
            var t = this;
            e._getNetWork({
                url: e.getNetAddresss("plugin.sign-buy.frontend.user-sign.index"),
                success: function(a) {
                    var e = a.data, i = e.result, s = e.msg, n = e.data, r = n.active_value, o = n.is_admin, d = n.require_pwd;
                    if (0 == i) return t.$toast(s);
                    t.setData({
                        active_value: r,
                        require_pwd: d,
                        is_admin: o
                    });
                }
            });
        },
        finish: function() {
            this.getData();
        },
        link: function(t) {
            "code" == t.currentTarget.dataset.url ? wx.navigateTo({
                url: "/packageF/sign_in_subscribe/".concat(t.currentTarget.dataset.url, "/").concat(t.currentTarget.dataset.url, "?type=2")
            }) : wx.navigateTo({
                url: "/packageF/sign_in_subscribe/".concat(t.currentTarget.dataset.url, "/").concat(t.currentTarget.dataset.url)
            });
        },
        handleInput: function(t) {
            this.setData({
                count: t.detail.value
            });
        },
        handle_password: function(t) {
            this.setData({
                password: t.detail.value
            });
        },
        sigin_handle: function(t) {
            var a = this, i = {
                stage_id: this.data.activity_id,
                amount: this.data.count,
                admin: this.data.index
            };
            0 == this.data.index && 1 == this.data.require_pwd && (i.pwd_type = 0 == this.data.pay_index ? "login" : "pay", 
            i.pwd = this.data.password), e._getNetWork({
                url: e.getNetAddresss("plugin.sign-buy.frontend.user-sign.submit"),
                data: i,
                success: function(t) {
                    var i = t.data, s = i.result, n = i.msg, r = i.data;
                    0 != s ? (e.tips(n), a.getData(), a.get_buy_data(), a.setData({
                        show_dialog: !1,
                        index: 0,
                        amount: "",
                        password: "",
                        show_pay: !1
                    })) : 0 == a.data.index && 1 == a.data.require_pwd && 1 == a.data.pay_index && 1 == r.password_error ? a.setData({
                        password_show: !0
                    }) : e.tips(n);
                }
            });
        },
        imgHeight: function(t) {
            var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width;
            parseInt(a) > this.data.LastHeight && (this.setData({
                Height: a
            }), this.data.LastHeight = parseInt(a));
        },
        BannerHeight: function(t) {
            var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width;
            parseInt(a) > this.data.Last_Banner_Height && (this.setData({
                Banner_Height: a
            }), this.data.Last_Banner_Height = parseInt(a));
        },
        confirm: function(t) {
            var a = t.currentTarget.dataset.type;
            if ("subscribe" == a) {
                if (this.data.count <= 0) return e.tips("请输入有效签到认购数量");
                0 == this.data.index ? 1 == this.data.require_pwd ? this.setData({
                    show_pay: !0
                }) : 0 == this.data.require_pwd && this.sigin_handle("subscribe") : 1 == this.data.index && this.sigin_handle("subscribe");
            }
            if ("pay" == a) {
                if ("" == this.data.password) return e.tips("请输入".concat(0 == this.data.pay_index ? "登录" : "支付", "密码"));
                this.sigin_handle("pay");
            }
        },
        closePay: function() {
            this.setData({
                show_pay: !1
            });
        },
        closeDialog: function() {
            this.setData({
                show_dialog: !1
            });
        },
        closePas: function() {
            this.setData({
                show_pay: !1
            });
        },
        choose: function(t) {
            var a = t.currentTarget.dataset, e = a.i;
            "member" == a.type ? this.setData({
                index: e,
                role: 1 == e ? "admin" : "member"
            }) : this.setData({
                pay_index: e
            });
        },
        onClickHide: function() {
            this.setData({
                password_show: !1
            });
        },
        _getBalancePwdInfo: function() {
            var t = this, a = e.getNetAddresss("member.balance-password.is-has-password");
            e._getNetWork({
                url: a,
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? t.setData({
                        is_has: e.data.is_has
                    }) : console.log(e.msg);
                },
                fail: function(t) {
                    console.log(t.msg);
                }
            });
        },
        password_handle: function(t) {
            "forget" == t.currentTarget.dataset.type ? this.data.is_has ? wx.navigateTo({
                url: "/packageA/member/balance_password/balance_password"
            }) : wx.navigateTo({
                url: "/packageA/member/set_balance_password/set_balance_password"
            }) : this.setData({
                password_show: !1
            });
        },
        clickHome: function() {
            wx.navigateTo({
                url: "/packageG/index/index"
            });
        },
        clickChat: function() {
            this.setData({
                show1: !0
            });
        }
    }
});